#pragma once

#include "fxcc/core/graph/common/pch.h"
#include "fxcc/core/graph/common/Condition.h"
#include "fxcc/core/graph/common/AnimationNode.h"
#include "fxcc/core/graph/common/AnimTransitionChannel.h"

namespace fxcc::graph::common
{
	struct AnimTransition :public fxcc::Base
	{
		int m_LeftId;

		int m_RightId;

		AnimationNode m_LeftAnim;

		AnimationNode m_RightAnim;

		float m_BlendTime{ 0.2f };

		float m_LeftAxis{ 0.0f };

		float m_RightAxis{ 0.f };

		float m_TransitionAxis{ 0.f };

		std::map<std::string, AnimTransitionChannel> m_Channels;

		void AddAxisTime(float deltaTime)
		{
			if (m_BlendTime)
			{
				m_TransitionAxis += deltaTime / m_BlendTime;
			}
		}

		void InitLeftAndRight()
		{
			m_Channels.clear();

			//for (const auto& [key1, value1] : m_LeftAnim.m_AnimationMap.m_Value->m_Channels)
			//{
			//	auto& transitionChannel = m_Channels[key1];
			//	transitionChannel.m_Entity = (e2d::Entity*)value1.m_Entity;
			//	transitionChannel.m_Left = value1;
			//	transitionChannel.m_ChannelName = key1;

			//}
			//for (const auto& [key1, value1] : m_RightAnim.m_AnimationMap.m_Value->m_Channels)
			//{
			//	auto& transitionChannel = m_Channels[key1];
			//	transitionChannel.m_Entity = (e2d::Entity*)value1.m_Entity;
			//	transitionChannel.m_Right = value1;
			//	transitionChannel.m_ChannelName = key1;
			//}

			ztclog::info("num channels is %d", m_Channels.size());
		}

		void UpdateEntityMap();
	};

};